package com.tencent.sr.iris.basic.saas.service.model.operate;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelProperty;
import com.tencent.sr.iris.activity.interfaces.response.group.operate.OperateSecondBoardResponse;
import com.tencent.sr.iris.user.core.service.interfaces.enums.UserLevelEnum;
import lombok.Data;

import java.util.Map;
import java.util.Optional;

@Data
public class OperateBoardSprintExportInfo {

    @ExcelProperty(value = "序号", index = 0)
    private int num;

    @ExcelProperty(value = "报名时间", index = 1)
    private String taskPhaseJoinTime;

    @ExcelProperty(value = "团长uid", index = 2)
    private String irisUid;

    @ExcelProperty(value = "unionId", index = 3)
    private String wechatUserUnionid;

    @ExcelProperty(value = "昵称", index = 4)
    private String wechatUserNickname;

    @ExcelProperty(value = "导师昵称", index = 5)
    private String advisorNickName;

    @ExcelProperty(value = "导师uid", index = 6)
    private String advisorUid;

    @ExcelProperty(value = "区域", index = 7)
    private String area;

    @ExcelProperty(value = "等级", index = 8)
    private String irisUidLevel;

    public void readFromSearchResponseData(OperateSecondBoardResponse response, Map<Long, String> orgMap) {
        this.setTaskPhaseJoinTime(response.getTaskPhaseJoinTime());
        this.setIrisUid(response.getIrisUid());
        this.setWechatUserUnionid(response.getWechatUserUnionid());
        this.setWechatUserNickname(response.getWechatUserNickname());
        this.setArea(orgMap.getOrDefault(response.getAreaId(), ""));

        String levelText = Optional.ofNullable(UserLevelEnum.getByValue(response.getIrisUidLevel()))
                .map(UserLevelEnum::getDesc).orElse(StrUtil.EMPTY);
        this.setIrisUidLevel(levelText);

        this.setAdvisorNickName(response.getAdvisorNickName());
        this.setAdvisorUid(response.getAdvisorUid());
    }

}
